<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>居民区党组织基本信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script type="text/javascript" src="/djzx/js/layer/layer.js" ></script>
<SCRIPT language=JavaScript type=text/JavaScript>
//查询模式：0代表查询，1代表高级查询
var queryMode = 0;

var name_layer = "";
var address_layer = "";
var tel_layer = "";
var secretary_layer = "";
var tel1_layer = "";
var director_layer = "";
var tel2_layer = ""; 

window.onload = function(){
	var flag = $('#flag').val();
	if(flag != ""){
		alert(flag);
	}
	$('#flag').val('');
}

function delParty(timeKey){
	var r = confirm("确定要删除吗?");
	if(r){
		$.post(
				"/djzx/CommunityPartyAction!delPartyInfo.action",
				{
					"communityParty.timeKey":timeKey
				},
				function(data){
					alert(data.message);
					if(data.success){
						location.href="/djzx/CommunityPartyAction!getPartyInfoListForPage.action";
					}
				},
				"json"
				)
	}
}

function toAddParty(){
	window.location.href="/djzx/backPage/community/addPartyInfo.jsp";
}

function toEditParty(timeKey){
	window.location.href="/djzx/CommunityPartyAction!toEditPartyInfo.action?communityParty.timeKey=" + timeKey;
}

function searchParty(){
	queryMode = 0;
	ajaxParty(1);
}

function firstPage(){
	ajaxParty(1);
}

function prevPage(){
	var start =parseInt($("#start").html());
	if(start <= 1){
		start = 1;
	}else{
		start--;
	}
	ajaxParty(start);
}

function nextPage(){
	var start =parseInt($("#start").html());
	var count = parseInt($("#pageCount").html());
	if(start >= count){
		start = count;
	}else{
		start++;
	}
	ajaxParty(start);
}

function endPage(){
	var last = parseInt($("#pageCount").html());
	ajaxParty(last);
}

function ajaxParty(start){
	var name = "";
	var address = "";
	var tel = "";
	var secretary = "";
	var tel1 = "";
	var director = "";
	var tel2 = ""; 
	
	if(queryMode == 0){ // 查询
		var param = $.trim($('#param').val());
		var paramValue = $.trim($('#paramValue').val());
		
		if(param == 'name'){
			name = paramValue;
		}else if(param == 'address'){
			address = paramValue;
		}else if(param == 'tel'){
			tel = paramValue;
		}else if(param == 'secretary'){
			secretary = paramValue;
		}else if(param == 'tel1'){
			tel1 = paramValue;
		}else if(param == 'director'){
			director = paramValue;
		}else if(param == 'tel2'){
			tel2 = paramValue;
		}
	}else if(queryMode == 1){ // 高级查询
		name = name_layer;
		address = address_layer;
		tel = tel_layer;
		secretary = secretary_layer;
		tel1 = tel1_layer;
		director = director_layer;
		tel2 = tel2_layer;
	} 
	
	$.ajax({
		url:'${pageContext.request.contextPath}/CommunityPartyAction!searchPartyList.action',
		data:{
			"page.currPage":start,
			"communityParty.name":name,
			"communityParty.address":address,
			"communityParty.tel":tel,
			"communityParty.secretary":secretary,
			"communityParty.tel1":tel1,
			"communityParty.director":director,
			"communityParty.tel2":tel2
		},
		type:'post',
		dataType:'json',
		success:function(data){
			var str="";
			if(data.map.length>0){
				$.each(data.map,function(i){
					str+='<tr><td class="td_01">'+data.map[i].index+
					'</td><td class="td_01">'+data.map[i].name+
					'</td><td class="td_01">'+data.map[i].address+
					/* '</td><td class="td_01">'+data.map[i].tel+ */
					'</td><td class="td_01">'+data.map[i].secretary+
					/* '</td><td class="td_01">'+data.map[i].tel1+
					'</td><td class="td_01">'+data.map[i].director+
					'</td><td class="td_01">'+data.map[i].tel2+ */
					'</td><td nowrap class="td_01"><a href="javascript:void(0)" onclick="toEditParty('+data.map[i].timeKey+')">编辑</a>|<a href="javascript:void(0)" onclick="delParty('+data.map[i].timeKey+')">删除</a></td></tr>';
				});
			}
			$("#nodeContent").html(str);
			$("#start").html(data.object.currPage);
			$("#pageCount").html(data.object.pageCount);
			$("#count").html(data.object.count);
		}
	}); 
}

function advancedQueryParty(){
	queryMode = 1;
	name_layer = $.trim($('#name').val());
	address_layer = $.trim($('#address').val());
	tel_layer = $.trim($('#tel').val());
	secretary_layer = $.trim($('#secretary').val());
	tel1_layer = $.trim($('#tel1').val());
	director_layer = $.trim($('#director').val());
	tel2_layer = $.trim($('#tel2').val());
	ajaxParty(1);
}

function tree(tag,imgTag){
	if($('#' + tag).css('display') == 'none'){
		$('#' + tag).show();
		$('#' + imgTag).attr('src','/djzx/images/minus.png');
	}else{
		$('#' + tag).hide();
		$('#' + imgTag).attr('src','/djzx/images/plus.png');
	}
}

function toMemberInfo(){
	window.location.href = "/djzx/CommunityMemberAction!getMemberInfoListForPage.action";
}

function toPartyActivity(partyName){
	window.location.href = "/djzx/CommunityPartyActivityAction!getPartyActivityListForPage.action?partyNameParam=" + encodeURI(encodeURI(partyName));
}

</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<input id="flag" value="${flag }" type="hidden"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">基本信息查询</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td_page">
	  <!-- 查询参数：
      <select name="param" id="param">
      	<option value="name">党组织名称</option>
        <option value="address">地址</option>
        <option value="tel">居委会电话</option>
        <option value="secretary">党支部书记</option>
        <option value="tel1">党支部书记联系方式</option>
        <option value="director">居委会主任</option>
        <option value="tel2">居委会主任联系方式</option>
      </select>
             参数值：
      <input name="paramValue" id="paramValue" type="text" class="input" size="10">
      <input type="button" class="buttonface02" value=" 查询 " onclick="">（暂不可用）
      <input type="button" class="buttonface02" value=" 高级查询 " id="">（暂不可用） -->
      <s:if test="#session.role.adminPower == 1 || (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '00')">
      <input type="button" class="buttonface02" value=" 居民区所有党员信息" onclick="toMemberInfo()">
      </s:if>
      <s:else>
      <input type="button" class="buttonface02" style="visibility: hidden;">
      </s:else>
	  <!-- <input type="button" class="buttonface02" value=" 新增党支部" onclick="toAddParty()"> -->
    </td>
  </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap class="td_top">序号</td>
    <td nowrap class="td_top">党组织名称</td>
    <td nowrap class="td_top">地址</td>
    <td nowrap class="td_top">居委会电话</td>
    <td nowrap class="td_top">党总支书记</td>
    <td nowrap class="td_top">书记联系方式</td>
    <td nowrap class="td_top">居委会主任</td>
	<td nowrap class="td_top">主任联系方式</td>
	<td nowrap class="td_top">其他信息</td>
  </tr>
  <tbody id="nodeContent">
  <s:iterator value="communityGeneralPartyList" var="cgp" status="statu1">
  <tr> 
    <td class="td_01">${statu1.index+1 }</td>
    <td class="td_01">
    	<img id="img_${statu1.index }" style="vertical-align: middle;" onClick="tree('child_${statu1.index }','img_${statu1.index }');" src="/djzx/images/plus.png" width="19" height="20">
    	<s:if test="#session.role.adminPower == 1 
    	|| (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '00')
    	|| (#session.role.twoLevelPower == 1 && #session.role.twoLevelNO == #cgp.timeKey)">
    	<a href="/djzx/CommunityPartyAction!toShowGeneralPartyInfo.action?communityGeneralParty.timeKey=${cgp.timeKey}" target="_blank">${cgp.name }</a>
    	</s:if>
    	<s:else>
    	${cgp.name }
    	</s:else>
    </td>
    <td class="td_01">${cgp.address }</td>
    <td class="td_01">${cgp.tel }</td>
    <td class="td_01">${cgp.secretary }</td>
    <td class="td_01">${cgp.tel1 }</td>
	<td class="td_01">${cgp.director }</td>
    <td class="td_01">${cgp.tel2 }</td>
    <td class="td_01">
    <a href="/djzx/CommunityProjectAction!getProjectListForPage.action?communityGeneralPartyKey=${cgp.timeKey }">项目</a>|
    <%-- <a href="/djzx/CommunityPartyActivityAction!getPartyActivityListForPage.action?partyName= + encodeURI(${cgp.name })">党建动态</a> --%>
    <a href="javascript:void(0);" onclick="toPartyActivity('${cgp.name }')">党建动态</a>
    </td>
  </tr>
  <tr>
  	<td colspan="9">
      <table id="child_${statu1.index }" style="display: none;" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
	      <td nowrap class="td_form03">党支部名称</td>
	      <td nowrap class="td_form03">地址</td>
	      <td nowrap class="td_form03">党支部书记</td>
		  <td nowrap class="td_form03">操作</td>
		  <td nowrap class="td_form03">其他信息</td>
	    </tr>
        <s:iterator value="communityPartyList" var="c" status="statu2">
  		<s:if test="#c.communityGeneralParty.timeKey==#cgp.timeKey">
        <tr>
	      <td class="td_form01">
	      	<s:if test="#session.role.adminPower == 1 
	    	|| (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '00')
	    	|| (#session.role.twoLevelPower == 1 && #session.role.twoLevelNO == #cgp.timeKey)">
	      	<a href="/djzx/CommunityPartyAction!toShowPartyInfo.action?communityParty.timeKey=${c.timeKey}" target="_blank">${c.name }</a>
	      	</s:if>
	      	<s:else>
	      	${c.name }
	      	</s:else>
	      </td>
	      <td class="td_form01">${c.address }</td>
	      <td class="td_form01">${c.secretary }</td>
		  <td nowrap class="td_form01">
		  	<s:if test="#session.role.adminPower == 1 
	    	|| (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '00')
	    	|| (#session.role.twoLevelPower == 1 && #session.role.twoLevelNO == #cgp.timeKey)">
			<a href="/djzx/CommunityPartyAction!toShowPartyInfo.action?communityParty.timeKey=${c.timeKey}" target="_blank">查看</a>|
			<a href="#" onclick="toEditParty(${c.timeKey})">编辑</a>|
			<a href="#" onclick="delParty(${c.timeKey })">删除</a>
			</s:if>
		  </td>
		  <td class="td_form01">
		  <a href="javascript:void(0);" onclick="toPartyActivity('${c.name }')">党建动态</a>
		  </td>
	    </tr>
	    </s:if>
	    </s:iterator>
  	  </table>
  	</td>
  </tr>
  </s:iterator>
  </tbody>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap width="95%" class="td_top"></td>
  </tr>
</table>
<table width="95%"  border="0" cellpadding="0" cellspacing="0" class="table02" align="center">
  <tr>
    <td height="30" align="right">
	    <img src="/djzx/images/1.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">首页</a>　
	    <img src="/djzx/images/2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">上一页</a>　 
	    <img src="/djzx/images/2-2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">下一页</a>　 
	    <img src="/djzx/images/3.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="">末页</a>　　
	         当前第<span id="start">${page.currPage}</span>页,共<span id="pageCount">${page.pageCount}</span>页,共<span id="count">${page.count}</span>条记录
    </td>
  </tr>
</table>
<script type="text/javascript">
$(document).ready(function(){
	var layerW = '800px';
	var layerH = '200px';
	   
	// 高级查询界面
	$('#advancedQuery').on('click', function(){ 
		var content = '<br><table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">'
				+ '<tr><td width="120" height="24" class="td_form01">党组织名称</td>' 
				+ '<td nowrap class=td_form02><input type="text" size="30" id="name" /></td>'
				+ '<td width="120" class="td_form01">地址</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="address" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">居委会电话</td>'
        		+ '<td nowrap class=td_form02><input type="text" size="30" id="tel" /></td>'
        		+ '<td class="td_form01">党支部书记</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="secretary" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">党支部书记联系方式</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="tel1" /></td>'
      			+ '<td class="td_form01">居委会主任</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="director" /></td></tr>'
      			+ '<tr><td class="td_form01">居委会主任联系方式</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="tel2" /></td></tr></table>'
      			+ '<br><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">'
      			+ '<tr><td align="center"><input name="Submit2" type="submit" class="buttonface" value="  查询  " onClick="advancedQueryParty()"></td></tr></table>';
   
		// 页面一打开就执行，放入ready是为了layer所需配件（css、扩展模块）加载完毕
		layer.ready(function(){ 
			//官网欢迎页
			layer.open({
				type: 1,
				//skin: 'layui-layer-lan',
				title: '高级查询',
				fix: false,
				shadeClose: true,
				maxmin: true,
				area: [layerW, layerH],
				content: content,
				end: function(){
					//layer.tips('试试相册模块？', '#photosDemo', {tips: 1})
				}
			});
		});
	});
});
</script>
</body>
</html>